﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Util;

namespace Club
{
    public partial class RegisterMember : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.txtName.Focus();
        }

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                DAL.User user = new DAL.User();
                user.Name = txtName.Text;
                user.Password = txtPassword.Text;
                user.Email = txtEmail.Text;
                user.FullName = txtName.Text;
                user.RoleId = (short)ROLE_ENUM.MEMBER;
                BLL.RegisterUser registerMember = new BLL.RegisterUser();
                registerMember.registerMember(user);
                if (user != null)
                {
                    Dictionary<string, object> sessionVar = (Dictionary<string, object>)Session["vars"];
                    sessionVar["userVar"] = user;
                    Session["vars"] = sessionVar;
                }
                Response.Redirect("Main.aspx");
            }
            catch (Exception ex)
            {
                WebCommon.ShowMsg(Response, ex.Message);
            }
  
        }
    }
}